import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { TokensService } from './tokens.service';
import { CreateTokenDto } from './dto/create-token.dto';
import { UpdateTokenDto } from './dto/update-token.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('Token')
@Controller('tokens')
export class TokensController {
  constructor(private readonly tokensService: TokensService) {}

  @ApiOperation({ summary: '创建Token' })
  @Post('create')
  create(@Body() createTokenDto: CreateTokenDto) {
    return this.tokensService.create(createTokenDto);
  }

  @ApiOperation({ summary: '查询所有Token' })
  @Get('queryAll')
  findAll() {
    return this.tokensService.findAll();
  }

  @ApiOperation({ summary: '查询Token' })
  @Get('query/:id')
  findOne(@Param('id') id: string) {
    return this.tokensService.findOne(+id);
  }

  @ApiOperation({ summary: '更新Token' })
  @Post('update')
  update(@Body() updateTokenDto: UpdateTokenDto) {
    return this.tokensService.update(updateTokenDto);
  }

  @ApiOperation({ summary: '删除Token' })
  @Post('delete/:id')
  remove(@Param('id') id: string) {
    return this.tokensService.remove(+id);
  }
}
